<template>
  <div v-loading="submitLoading" class="sourceContClass">
    <!-- <div class="titleParser">
        <span>目录编制--{{status==='add'?'新增':status==='edit'?'编辑':status==='change'?'变更':'查看'}}</span>
        <el-button type="primary" @click="btnBack">返回</el-button>
      </div> -->
    <el-row :gutter="20">
      <el-form :model="formData" class="demo-form-inline" ref="ruleForm">
        <el-col :span="24">
          <el-form-item label="">
            <span style="font-size:16px;">基本信息</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="目录编号" prop="catalog_code"
            :rules="[{required: false, message: '请输入目录编号', trigger: 'blur'}]">
            <!-- <el-input v-model="formData.catalog_code" placeholder="请输入目录编号" :disabled="true" class="itemclass"></el-input> -->
            <el-select v-model="formData.catalog_code" placeholder="目录编号" class="itemclass" :disabled="true">
              <el-option :label="codelabel" :value="codevalue"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="目录分类" prop="menu_id" :rules="[{required: true, message: '请选择目录分类', trigger: 'blur'}]">
            <el-select v-model="formData.menu_id" placeholder="请选择目录分类" class="itemclass"
              :disabled="disabledparser||status==='change'">
              <el-option :label="item.label" :value="item.value" v-for="item in menuOptions" :key="item.id"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="目录名称" prop="name" :rules="[{required: true, message: '请输入目录名称', trigger: 'blur'}]">
            <el-input v-model="formData.name" placeholder="请输入目录名称" :disabled="disabledparser"
              class="itemclass"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="是否电子证照" prop="is_permit"
            :rules="[{required: true, message: '请选择是否电子证照', trigger: 'blur'}]">
            <el-select v-model="formData.is_permit" placeholder="请选择是否电子证照" class="itemclass"
              :disabled="disabledparser">
              <el-option label="是" :value="0"></el-option>
              <el-option label="否" :value="1"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="与政务服务事项有无关联" prop="is_matter"
            :rules="[{required: true, message: '请选择与政务服务事项有无关联', trigger: 'blur'}]">
            <el-select v-model="formData.is_matter" placeholder="请选择与政务服务事项有无关联" class="itemclass"
              :disabled="disabledparser">
              <el-option label="是" :value="0"></el-option>
              <el-option label="否" :value="1"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="数据所属事项名称" prop="matter_name">
            <el-input v-model="formData.matter_name" placeholder="请输入数据所属事项名称" class="itemclass"
              :disabled="disabledparser"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="所属事项编码" prop="matter_code">
            <el-input v-model="formData.matter_code" placeholder="请输入所属事项编码" class="itemclass"
              :disabled="disabledparser"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="办理该事项产生的结果名称" prop="matter_result">
            <el-input v-model="formData.matter_result" placeholder="请输入办理该事项产生的结果名称" class="itemclass"
              :disabled="disabledparser"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="与政务服务事项无关联原因" prop="matter_reason">
            <el-input v-model="formData.matter_reason" placeholder="请输入与政务服务事项无关联原因" class="itemclass"
              :disabled="disabledparser"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="共享方式" prop="share_mode" :rules="[{required: true, message: '请选择共享方式', trigger: 'blur'}]">
            <el-select v-model="formData.share_mode" placeholder="请选择共享方式" class="itemclass"
              :disabled="disabledparser||status==='change'">
              <el-option-group v-for="group in shareList" :key="group.label" :label="group.label">
                <el-option v-for="item in group.options" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-option-group>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="共享属性" prop="share_property"
            :rules="[{required: true, message: '请选择共享属性', trigger: 'blur'}]">
            <el-select v-model="formData.share_property" placeholder="请选择共享属性" class="itemclass"
              :disabled="disabledparser">
              <el-option :label="item.label" :value="item.value" v-for="item in shareOptions"
                :key="item.value"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12" v-if="formData.share_property==2||formData.share_property==3">
          <el-form-item label="共享条件" prop="share_condition"
            :rules="[{required: true, message: '请填写共享条件', trigger: 'blur'}]">
            <el-input v-model="formData.share_condition" type="textarea" :disabled="disabledparser" :rows="4"
              maxlength="500"
              placeholder="有条件共共类的政务信息咨源，应标明使用要求，包括作为行收依据、工作参专、共享条件、共享范用，用于数据校核、业务协同等；对于不予共享类的政务信点资源，应注明机关的法律、行政法规或中央、国务院政策依据。如无条件，请填与无。"
              class="itemclass"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="">
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="开放类型" prop="open_type" :rules="[{required: true, message: '请选择开放类型', trigger: 'blur'}]">
            <el-select v-model="formData.open_type" placeholder="请选择开放类型" class="itemclass"
              :disabled="disabledparser||status==='change'">
              <el-option :label="item.label" :value="item.value" v-for="item in openOptions"
                :key="item.value"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12" v-if="formData.open_type==3">
          <el-form-item label="开放条件" prop="open_condition"
            :rules="[{required: true, message: '请填写开放条件', trigger: 'blur'}]">
            <el-input v-model="formData.open_condition" type="textarea" :disabled="disabledparser" :rows="4"
              maxlength="500" placeholder="对向社会开放的资源条件进行描述。如无条件，请填与无。" class="itemclass"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="">
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="资源信息格式" prop="info_property"
            :rules="[{required: true, message: '请选择资源信息格式', trigger: 'blur'}]">
            <el-select v-model="formData.info_property" placeholder="请选择开放类型" class="itemclass"
              :disabled="disabledparser">
              <el-option-group v-for="group in sourceList" :key="group.label" :label="group.label">
                <el-option v-for="item in group.options" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-option-group>

            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="">
            <span style="font-size:16px">其他信息</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="应用场景" prop="apply_scene"
            :rules="[{required: true, message: '请选择应用场景', trigger: 'blur'}]">
            <el-select v-model="formData.apply_scene" placeholder="请选择应用场景" class="itemclass"
              :disabled="disabledparser">
              <el-option :label="item.label" :value="item.value" v-for="item in sceneOptions"
                :key="item.value"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="目录提供方" prop="dept_id" :rules="[{required: true, message: '请选择目录提供方', trigger: 'blur'}]">
            <el-select v-model="formData.dept_id" placeholder="请选择目录提供方" :disabled="true" class="itemclass">
              <el-option :label="item.name" :value="item.id" v-for="item in departAllList" :key="item.id"></el-option>
            </el-select>

          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="提供渠道" prop="channel" :rules="[{required: true, message: '请选择提供渠道', trigger: 'blur'}]">
            <el-select v-model="formData.channel" placeholder="请选择提供渠道" class="itemclass" :disabled="disabledparser">
              <el-option :label="item.label" :value="item.value" v-for="item in channelOptions"
                :key="item.value"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="所属领域" prop="domain" :rules="[{required: true, message: '请选择所属领域', trigger: 'blur'}]">
            <el-select v-model="formData.domain" placeholder="请选择所属领域" class="itemclass" :disabled="disabledparser">
              <el-option :label="item.label" :value="item.value" v-for="item in domainOptions"
                :key="item.value"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="更新周期" prop="period_type"
            :rules="[{required: true, message: '请选择更新周期', trigger: 'blur'}]">
            <el-select v-model="formData.period_type" placeholder="请选择更新周期" class="itemclass"
              :disabled="disabledparser">
              <el-option :label="item.label" :value="item.value" v-for="item in period_typeOptions"
                :key="item.value"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="目录摘要" prop="abstract_info">
            <el-input v-model="formData.abstract_info" type="textarea" :disabled="disabledparser" :rows="4"
              placeholder="请输入目录摘要" class="itemclass"></el-input>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
    <div class="subformtable">
      <span>信息项</span>
    </div>
    <el-form :model="subformobj" ref="subformrule">
      <el-table @selection-change="subChange" :data="subtableData" style="width: 100%">
        <el-table-column type="selection" width="55">
        </el-table-column>
        <el-table-column label="信息项名称" width="180">
          <template slot-scope="scope">
            <el-form-item :prop="'info_name'+scope.row.lenbbb" label=""
              :rules="[{required: true, message: '请输入信息项名称', trigger: 'blur'}]">
              <el-input placeholder="请输入信息项名称" v-model="scope.row.info_name" class="itemclass"
                :disabled="disabledparser" @change="subinfochange($event,'info_name'+scope.row.lenbbb)"></el-input>
            </el-form-item>
          </template>
          <template slot="header">
            <span style="color:red;">* </span>信息项名称
          </template>
        </el-table-column>
        <el-table-column label="信息项英文名称" width="180">
          <template slot-scope="scope">
            <el-form-item :prop="'info_code'+scope.row.lenbbb" label=""
              :rules="[{required: true, message: '请输入信息项英文名称', trigger: 'blur'}]">
              <el-input placeholder="请输入信息项英文名称" @change="subinfochange($event,'info_code'+scope.row.lenbbb)"
                v-model="scope.row.info_code" class="itemclass" :disabled="disabledparser"></el-input>
            </el-form-item>

          </template>
          <template slot="header">
            <span style="color:red;">* </span>信息项英文名称
          </template>
        </el-table-column>
        <el-table-column label="数据类型" width="180">
          <template slot-scope="scope">
            <el-form-item :prop="'type'+scope.row.lenbbb" label=""
              :rules="[{required: true, message: '请选择数据类型', trigger: 'blur'}]">
              <el-select v-model="scope.row.type" @change="subinfochange($event,'type'+scope.row.lenbbb)"
                placeholder="请选择数据类型" class="itemclass" :disabled="disabledparser">
                <el-option :label="item.label" :value="item.value" v-for="item in subtypeOptions"
                  :key="item.value"></el-option>
              </el-select>
            </el-form-item>

          </template>
          <template slot="header">
            <span style="color:red;">* </span>数据类型
          </template>
        </el-table-column>
        <el-table-column label="数据敏感级别" width="180">
          <template slot-scope="scope">
            <el-form-item :prop="'sensitive_level'+scope.row.lenbbb" label=""
              :rules="[{required: true, message: '请选择数据敏感级别', trigger: 'blur'}]">
              <el-select v-model="scope.row.sensitive_level"
                @change="subinfochange($event,'sensitive_level'+scope.row.lenbbb)" placeholder="请选择数据敏感级别"
                class="itemclass" :disabled="disabledparser">
                <el-option :label="item.label" :value="item.value" v-for="item in subsensitiveOptions"
                  :key="item.value"></el-option>
              </el-select>
            </el-form-item>

          </template>
          <template slot="header">
            <span style="color:red;">* </span>数据敏感级别
          </template>
        </el-table-column>
        <el-table-column label="来源系统" width="180">
          <template slot-scope="scope">
            <el-form-item :prop="'source_system'+scope.row.lenbbb" label=""
              :rules="[{required: false, message: '请输入来源系统', trigger: 'blur'}]">
              <el-input placeholder="请输入来源系统" @change="subinfochange($event,'source_system'+scope.row.lenbbb)"
                v-model="scope.row.source_system" class="itemclass" :disabled="disabledparser"></el-input>
            </el-form-item>

          </template>
        </el-table-column>
        <el-table-column label="信息项长度" width="180">
          <template slot-scope="scope">
            <el-form-item :prop="'info_size'+scope.row.lenbbb" label=""
              :rules="[{required: true, message: '请输入整数信息项长度',pattern:/^\d+$/, trigger: 'blur'}]">
              <el-input placeholder="请输入信息项长度" @change="subinfochange($event,'info_size'+scope.row.lenbbb)"
                v-model="scope.row.info_size" class="itemclass" :disabled="disabledparser"></el-input>
            </el-form-item>

          </template>
          <template slot="header">
            <span style="color:red;">* </span>信息项长度
          </template>
        </el-table-column>
        <el-table-column label="共享类型" width="180">
          <template slot-scope="scope">
            <el-form-item :prop="'share_type'+scope.row.lenbbb" label=""
              :rules="[{required: true, message: '请选择共享类型', trigger: 'blur'}]">
              <el-select v-model="scope.row.share_type" @change="subinfochange($event,'share_type'+scope.row.lenbbb)"
                placeholder="请选择共享类型" class="itemclass" :disabled="disabledparser||status==='change'">
                <el-option :label="item.label" :value="item.value" v-for="item in shareOptions"
                  :key="item.value"></el-option>
              </el-select>
            </el-form-item>

          </template>
          <template slot="header">
            <span style="color:red;">* </span>共享类型
          </template>
        </el-table-column>
        <el-table-column label="共享条件" width="180">
          <template slot-scope="scope">
            <el-form-item :prop="'none_share'+scope.row.lenbbb" label=""
              :rules="[{required: false, message: '请输入共享条件', trigger: 'blur'}]">
              <el-input placeholder="请输入共享条件" @change="subinfochange($event,'none_share'+scope.row.lenbbb)"
                v-model="scope.row.none_share" class="itemclass" :disabled="disabledparser"></el-input>
            </el-form-item>

          </template>
        </el-table-column>
      </el-table>
    </el-form>
    <div style="display:flex;justify-content: center;margin:15px;" v-if="!disabledparser">
      <el-button size="small" type="primary" @click="submitForm('ruleForm')">提交</el-button>
      <el-button size="small" @click="resetForm('ruleForm')" style="margin:0 10px;">重置</el-button>
      <el-button size="small" @click="cancelForm('ruleForm')">取消</el-button>
    </div>
  </div>
</template>
  <script>
import { getAutomaticCode } from '@/api/custom/autoCoding.js'
import { sourceTestList, geDeptList } from '@/api/custom/formDesigner.js'
import { getUserProfile as getCurUser } from '@/api/system/user.js'
import { deepClone } from '@/utils'
export default {
  data() {
    return {
      departAllList: [],
      subdel: [],
      submitLoading: false,
      subformobj: {},
      codelabel: '',
      deptlabel: '',
      deptvalue: '',
      codevalue: '',
      subsensitiveOptions: [
        { label: '1级', value: 1 },
        { label: '2级', value: 2 },
        { label: '3级', value: 3 },
        { label: '4级', value: 4 }
      ],
      subtypeOptions: [
        { label: '字符串型C', value: 1 },
        { label: '数值型N', value: 2 },
        { label: '货币型Y', value: 3 },
        { label: '日期型D', value: 4 },
        { label: '日期时间型T', value: 5 },
        { label: '逻辑型L', value: 6 },
        { label: '备注型M', value: 7 },
        { label: '通用型G', value: 8 },
        { label: '双精度型B', value: 9 },
        { label: '整型I', value: 10 },
        { label: '浮点型F', value: 11 },
        { label: '二进制blob', value: 12 },
        { label: '长文本text', value: 13 }
      ],
      shareOptions: [
        {
          label: '无条件共享',
          value: 1
        },
        {
          label: '有条件共享',
          value: 2
        },
        {
          label: '不予共享',
          value: 3
        }
      ],
      openOptions: [
        {
          label: '可对社会开放',
          value: 1
        },
        {
          label: '不可对社会开放',
          value: 2
        },
        {
          label: '部分对社会开放',
          value: 3
        }
      ],
      sceneOptions: [
        {
          label: '其他',
          value: 0
        },
        {
          label: '政务服务',
          value: 1
        },
        {
          label: '公共服务',
          value: 2
        },
        {
          label: '监管',
          value: 3
        }
      ],
      channelOptions: [
        {
          label: '政务外网',
          value: 1
        },
        {
          label: '互联网',
          value: 2
        },
        {
          label: '专网',
          value: 3
        }
      ],
      domainOptions: [
        { label: '科技创新', value: '01' },
        { label: '商贸流通', value: '02' },
        { label: '社会救助', value: '03' },
        { label: '城建住房', value: '04' },
        { label: '教育文化', value: '05' },
        { label: '工业农业', value: '06' },
        { label: '机构团体', value: '07' },
        { label: '地理空间', value: '08' },
        { label: '资源能源', value: '09' },
        { label: '市场监管', value: 10 },
        { label: '生活服务', value: 11 },
        { label: '生态环境', value: 12 },
        { label: '交通运输', value: 13 },
        { label: '安全生产', value: 14 },
        { label: '社保就业', value: 15 },
        { label: '医疗卫生', value: 16 },
        { label: '信用服务', value: 17 },
        { label: '公共安全', value: 18 },
        { label: '财税金融', value: 19 },
        { label: '气象服务', value: 20 },
        { label: '法律服务', value: 21 },
        { label: '新冠疫苗', value: 22 },
        { label: '其他', value: 23 }
      ],
      period_typeOptions: [
        { label: '其他', value: 1 },
        { label: '每日', value: 2 },
        { label: '每周', value: 3 },
        { label: '每月', value: 4 },
        { label: '每季度', value: 5 },
        { label: '每半年', value: 6 },
        { label: '每年', value: 7 },
        { label: '实时', value: 8 }
      ],
      sourceList: [
        {
          label: '电子文件',
          options: [
            { label: 'doc', value: '0101' },
            { label: 'docx', value: '0102' },
            { label: 'html', value: '0103' },
            { label: 'OFD', value: '0104' },
            { label: 'pdf', value: '0105' },
            { label: 'ppt', value: '0106' },
            { label: 'txt', value: '0107' },
            { label: 'wps', value: '0108' },
            { label: 'xml', value: '0109' },
            { label: 'dbf', value: '0110' },
            { label: 'bmp', value: '0111' },
            { label: '其他', value: '0100' }
          ]
        },
        {
          label: '电子表格',
          options: [
            { label: 'et', value: '0201' },
            { label: 'xls', value: '0202' },
            { label: 'xlsx', value: '0203' },
            { label: '其他', value: '0200' }
          ]
        },
        {
          label: '数据库',
          options: [
            { label: 'access', value: '0301' },
            { label: 'db2', value: '0302' },
            { label: 'dbase', value: '0303' },
            { label: 'dbf', value: '0304' },
            { label: 'Dm', value: '0305' },
            { label: 'KingbaseES', value: '0306' },
            { label: 'oracle', value: '0307' },
            { label: 'sqlServer', value: '0308' },
            { label: 'sybase', value: '0309' },
            { label: 'mysql', value: '0310' },
            { label: 'GBase', value: '0311' },
            { label: 'Hbase', value: '0312' },
            { label: 'hdfs', value: '0313' },
            { label: 'EsgynDB', value: '0314' },
            { label: 'redis', value: '0315' },
            { label: 'mongodb', value: '0316' },
            { label: '其他', value: '0300' }
          ]
        },
        {
          label: '图形图像',
          options: [
            { label: 'bmp', value: '0401' },
            { label: 'gif', value: '0402' },
            { label: 'jpg', value: '0403' },
            { label: '其他', value: '0400' }
          ]
        },
        {
          label: '流媒体',
          options: [
            { label: 'mpg', value: '0501' },
            { label: 'rm', value: '0502' },
            { label: 'swf', value: '0503' },
            { label: '其他', value: '0500' }
          ]
        },
        {
          label: '自描述格式',
          options: [
            { label: '表格驱动码', value: '0601' },
            { label: '其他', value: '0600' }
          ]
        }
      ],
      shareList: [
        {
          label: '共享平台方式',
          options: [
            {
              label: '接口',
              value: '0101'
            },
            {
              label: '数据库',
              value: '0102'
            },
            {
              label: '文件',
              value: '0103'
            }
          ]
        },
        {
          label: '邮件或介质',
          options: [
            {
              label: '邮件',
              value: '0201'
            },
            {
              label: '拷盘',
              value: '0202'
            },
            {
              label: '纸质报表',
              value: '0203'
            },
            {
              label: '电子文档',
              value: '0204'
            }
          ]
        }
      ],
      menuOptions: [],
      formData: {
        catalog_code: '',
        menu_id: '',
        name: '',
        is_permit: '',
        is_matter: '',
        matter_name: '',
        matter_code: '',
        matter_result: '',
        matter_reason: '',
        share_mode: '',
        share_property: '',
        share_condition: '',
        open_type: '',
        open_condition: '',
        info_property: '',
        apply_scene: '',
        dept_id: '',
        channel: '',
        domain: '',
        period_type: '',
        abstract_info: ''
      },
      subtableData: [],
      formObj: [
        { name: 'open_condition', type: 'longtext', value: 1 },
        { name: 'open_type', type: 'varchar', value: 1 },
        { name: 'share_mode', type: 'varchar', value: 1 },
        { name: 'info_property', type: 'varchar', value: 1 },
        { name: 'share_condition', type: 'longtext', value: '1' },
        { name: 'catalog_code', type: 'varchar', value: 'aa' },
        { name: 'menu_id', type: 'int', value: 1 },
        { name: 'name', type: 'varchar', value: 'er' },
        { name: 'is_permit', type: 'int', value: 1 },
        { name: 'is_matter', type: 'int', value: 1 },
        { name: 'matter_name', type: 'varchar', value: 'fwe' },
        { name: 'matter_code', type: 'varchar', value: 'b' },
        { name: 'matter_result', type: 'varchar', value: 'we' },
        { name: 'matter_reason', type: 'varchar', value: 'sdf' },
        { name: 'share_property', type: 'varchar', value: '1' },
        { name: 'apply_scene', type: 'varchar', value: '2' },
        { name: 'dept_id', type: 'int', value: '100' },
        { name: 'channel', type: 'varchar', value: '1' },
        { name: 'domain', type: 'varchar', value: '05' },
        { name: 'period_type', type: 'varchar', value: '6' },
        { name: 'abstract_info', type: 'varchar', value: 'fww' }
      ],
      subObj: [
        { type: 'varchar', name: 'info_name', value: 'wer' },
        { type: 'varchar', name: 'info_code', value: 'wer' },
        { type: 'int', name: 'info_size', value: 'wer' },
        { type: 'varchar', name: 'type', value: 2 },
        { type: 'varchar', name: 'sensitive_level', value: '3' },
        { type: 'varchar', name: 'source_system', value: 'w22' },
        { type: 'varchar', name: 'share_type', value: '3' },
        { type: 'varchar', name: 'none_share', value: 'hryrty' }
      ],
      disabledparser: false
    }
  },
  props: ['tableName', 'status', 'originData', 'childCurrent'],
  created() {
    this.initData()

    this.getMenus()
    // this.getAutoCode()
    // this.getCurUser();
    this.getAllDepart()
    if (this.status === 'view') {
      this.disabledparser = true
    }
  },
  methods: {
    getCurUser() {
      getCurUser({}).then((res) => {
        // console.log(res,'kokok');
        if (res.code === 0) {
          this.deptlabel = res.data.dept.name
          this.deptvalue = this.deptvalue || res.data.dept.id
          this.formData.dept_id = this.deptvalue
        }
      })
    },
    getAllDepart() {
      geDeptList([]).then((res) => {
        this.departAllList = [...res.data] || []
        // list.forEach(cur => {
        //     this.departMap.set(cur.id + '', cur.name)
        // })
      })
    },
    subinfochange(e, a) {
      console.log(e, a)
      this.$nextTick(() => {
        this.$set(this.subformobj, a, e)
      })
      if (a.includes('share_type')) {
        this.setShareType()
      }
    },
    deleteTable() {
      let arr = this.subdel.map((item) => {
        return item.lenbbb
      })
      let arrval = this.subtableData.filter((item) => {
        return !arr.includes(item.lenbbb)
      })
      this.subtableData = arrval
      this.$refs.subformrule.clearSelection()
      this.subdel = []
    },
    subChange(selection) {
      console.log(selection, 'selection')
      this.subdel = selection
    },
    cancelForm() {
      this.$emit('btnBack')
    },
    initData() {
      if (Object.keys(this.originData).length) {
        for (let info in this.formData) {
          this.formData[info] = this.originData[info]
          if (
            /^\d+$/.test(this.formData[info]) &&
            (this.formData[info] + '').slice(0, 1) !== '0'
          ) {
            this.formData[info] = Number(this.formData[info])
          }
          if (this.formData[info] === '0') {
            this.formData[info] = Number(this.formData[info])
          }
        }
        if (
          this.originData.childTableStore &&
          this.originData.childTableStore.length
        ) {
          this.originData.childTableStore[0].data.forEach((item, ind) => {
            let obj = {
              info_name: '',
              info_code: '',
              type: '',
              sensitive_level: '',
              source_system: '',
              info_size: '',
              share_type: '',
              none_share: '',
              lenbbb: ind
            }
            for (let inp in obj) {
              let str = '' + inp + ind
              obj[inp] = item[inp]
              obj.lenbbb = ind
              this.$set(this.subformobj, str, obj[inp])
              if (
                /^\d+$/.test(obj[inp]) &&
                (obj[inp] + '').slice(0, 1) !== '0'
              ) {
                obj[inp] = Number(obj[inp])
                this.$set(this.subformobj, str, obj[inp])
              }
              if (obj[inp] === '0') {
                obj[inp] = Number(obj[inp])
                this.$set(this.subformobj, str, obj[inp])
              }
            }
            this.subtableData.push(obj)
          })
          this.setShareType()
        }
      }
    },
    setShareType() {
      let sharearr = this.subtableData.map((sub) => {
        return sub.share_type
      })
      let a = sharearr.every((item) => {
        return item == 1
      })
      let b = sharearr.some((item) => {
        return item == 2
      })
      let c = sharearr.every((item) => {
        return item == 3
      })
      if (a) {
        this.formData.share_property = 1
      } else if (c) {
        this.formData.share_property = 3
      } else if (b) {
        this.formData.share_property = 2
      } else {
        this.formData.share_property = 1
      }
    },
    //重置
    resetForm() {
      if (Object.keys(this.originData).length) {
        this.initData()
      } else {
        this.formData = {
          catalog_code: '',
          menu_id: '',
          name: '',
          is_permit: '',
          is_matter: '',
          matter_name: '',
          matter_code: '',
          matter_result: '',
          matter_reason: '',
          share_mode: '',
          share_property: '',
          share_condition: '',
          open_type: '',
          open_condition: '',
          info_property: '',
          apply_scene: '',
          dept_id: '',
          channel: '',
          domain: '',
          period_type: '',
          abstract_info: ''
        }
      }

      this.getAutoCode()
    },
    submitForm() {
      let _this = this
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          // alert('submit!');
          if (!_this.subtableData.length) {
            _this.$message.error('请添加子表单')
          } else {
            this.$refs['subformrule'].validate((val) => {
              if (val) {
                _this.insertform()
              } else {
                console.log('error submit!!')
                return false
              }
            })
          }
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    insertform() {
      this.submitLoading = true
      let sysFromInsertDataVo = {
        data: [],
        dataType: '2',
        repeatVerifyList: [],
        tableName: this.tableName
      }
      let sysFromInsertDataVoList = []
      for (let val in this.formData) {
        if (
          this.formData[val] !== '' &&
          this.formData[val] !== null &&
          this.formData[val] !== undefined
        ) {
          this.formObj.forEach((item) => {
            if (item['name'] === val) {
              let info = JSON.parse(JSON.stringify(item))
              info.value = this.formData[val]
              sysFromInsertDataVo.data.push(info)
            }
          })
        }
      }
      this.subtableData.forEach((sub, index) => {
        sysFromInsertDataVoList.push({
          data: [],
          dataId: this.status !== 'add' ? this.childCurrent : '',
          tableName: 'catalog_infos'
        })
        for (let val in sub) {
          if (sub[val] !== '' && sub[val] !== null && sub[val] !== undefined) {
            this.subObj.forEach((item) => {
              if (item['name'] === val) {
                let info = JSON.parse(JSON.stringify(item))
                info.value = sub[val]
                sysFromInsertDataVoList[index].data.push(info)
              }
            })
          }
        }
      })
      let params = {
        sysFromInsertDataVo,
        sysFromInsertDataVoList
      }
      this.$emit('insertParams', params)
    },
    insertTable() {
      let len = Date.now()
      this.subtableData.push({
        info_name: '',
        info_code: '',
        type: '',
        sensitive_level: '',
        source_system: '',
        info_size: '',
        share_type: '',
        none_share: '',
        lenbbb: len
      })
    },
    getMenus() {
      sourceTestList(152).then((rsp) => {
        if (rsp.code === 0) {
          let option = rsp.data?.rowMaps.map((item) => {
            return {
              label: item['classify_name'],
              value: item.id
            }
          })
          this.menuOptions = option
          if (Object.keys(this.originData).length) {
            let k = option.find((item) => {
              return item.label === this.formData['menu_id']
            })
            this.formData['menu_id'] = k.value
          }
        }
      })
    },
    getAutoCode() {
      let params = {
        tableName: this.tableName,
        column: 'catalog_code',
        encodeId: 42
      }

      // console.log(getAutomaticCode, 'getAutomaticCode')
      getAutomaticCode(params).then((res) => {
        console.log(res, 'ppopop')
        if (res.code === 0) {
          let str = res.data.storeData === ' ' ? ' ' : res.data.storeData //展示隐藏值
          this.codelabel = res.data.showData
          this.codevalue = str
          this.formData.catalog_code = str
        }
      })
    },
    btnBack() {
      this.$emit('btnBack')
    }
  }
}
</script>
  <style scoped>
.titleParser {
  padding-bottom: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
.titleParser span {
  font-size: 18px;
}
.itemclass {
  width: 100% !important;
}
.subformtable {
  margin: 10px;
  display: flex;
  justify-content: space-between;
}
.subformtable span {
  font-size: 16px;
  font-weight: bold;
}
/deep/ .el-select-group__title {
  color: #333;
  font-weight: bold;
  font-size: 16px;
}

/deep/.el-step__title {
  cursor: pointer !important;
}

.sourceContClass /deep/ .el-input.is-disabled .el-input__inner {
  color: black;
  border: none;
}
.sourceContClass /deep/ .el-textarea.is-disabled .el-textarea__inner {
  color: black;
}
.sourceContClass
  /deep/
  .el-radio__input.is-disabled.is-checked
  .el-radio__inner {
  background-color: #1890ff;
}
.sourceContClass
  /deep/
  .el-radio__input.is-disabled.is-checked
  .el-radio__inner::after {
  background-color: white;
}

.sourceContClass
  /deep/
  .el-radio.is-disabled.is-checked
  /deep/
  .el-radio__input.is-disabled
  + span.el-radio__label {
  color: #1890ff;
}
.sourceContClass /deep/ .el-radio.is-disabled.is-checked .el-radio__label {
  color: #1890ff;
}

.sourceContClass
  /deep/
  .el-checkbox__input.is-disabled.is-checked
  .el-checkbox__inner {
  background-color: #1890ff;
}
.sourceContClass
  /deep/
  .el-checkbox__input.is-disabled.is-checked
  .el-checkbox__inner::after {
  border-color: white;
}

.sourceContClass
  /deep/
  .el-checkbox.is-disabled.is-checked
  /deep/
  .el-checkbox__input.is-disabled
  + span.el-checkbox__label {
  color: #1890ff;
}
.sourceContClass
  /deep/
  .el-checkbox.is-disabled.is-checked
  .el-checkbox__label {
  color: #1890ff;
}

.sourceContClass
  /deep/
  .el-input.el-input--medium.is-disabled.el-input--suffix
  /deep/
  .el-input.is-disabled
  .el-input__inner {
  border: none;
}

.sourceContClass /deep/ .el-icon-arrow-up:before {
  content: '';
}
.sourceContClass /deep/ .el-icon-arrow-down:before {
  content: '';
}
.sourceContClass /deep/ .el-textarea.is-disabled .el-textarea__inner {
  border: none;
}
.sourceContClass /deep/ .el-range-editor.is-disabled {
  border: none;
}
.sourceContClass /deep/ .el-range-editor.is-disabled input {
  color: black;
}
.sourceContClass /deep/ .el-range-editor.is-disabled .el-range-separator {
  color: black;
}

.sourceContClass
  /deep/
  .el-input.el-input--small.is-disabled.el-input-group.el-input-group--append.el-input--suffix
  /deep/
  .el-input-group__append {
  border: none;
}

.sourceContClass
  /deep/
  .el-input.el-input--small.is-disabled.el-input-group.el-input-group--append.el-input--suffix
  /deep/
  .el-button.el-button--primary.el-button--medium.is-disabled
  /deep/
  .fa-map-marker:before {
  content: '';
}
</style>